import 'dart:developer' as developer;

class Logger {
  static const String _tag = 'MyApp';
  
  static void info(String message, {String? tag, DateTime? time}) {
    final actualTag = tag ?? _tag;
    final timestamp = time ?? DateTime.now();
    developer.log(
      message,
      name: actualTag,
      level: 500, // INFO level
      time: timestamp,
    );
    print('[$_tag][INFO] ${timestamp.toIso8601String()} $actualTag: $message');
  }

  static void error(String message, {String? tag, DateTime? time, Object? exception, StackTrace? stackTrace}) {
    final actualTag = tag ?? _tag;
    final timestamp = time ?? DateTime.now();
    developer.log(
      message,
      name: actualTag,
      level: 1000, // ERROR level
      time: timestamp,
      error: exception,
      stackTrace: stackTrace,
    );
    print('[$_tag][ERROR] ${timestamp.toIso8601String()} $actualTag: $message');
  }

  static void debug(String message, {String? tag, DateTime? time}) {
    final actualTag = tag ?? _tag;
    final timestamp = time ?? DateTime.now();
    developer.log(
      message,
      name: actualTag,
      level: 300, // DEBUG level
      time: timestamp,
    );
    print('[$_tag][DEBUG] ${timestamp.toIso8601String()} $actualTag: $message');
  }

  static void warning(String message, {String? tag, DateTime? time}) {
    final actualTag = tag ?? _tag;
    final timestamp = time ?? DateTime.now();
    developer.log(
      message,
      name: actualTag,
      level: 700, // WARNING level
      time: timestamp,
    );
    print('[$_tag][WARNING] ${timestamp.toIso8601String()} $actualTag: $message');
  }
}